--[[----------------------------------------------------------------------------
    This file is part of yalps.

    yalps is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    yalps is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with yalps.  If not, see <http://www.gnu.org/licenses/>.
------------------------------------------------------------------------------]]
--[[----------------------------------------------------------------------------
    Defines this plugin menu item called in Export menu
------------------------------------------------------------------------------]]

local LrFunctionContext = import 'LrFunctionContext'
local LrBinding = import 'LrBinding'
local LrDialogs = import 'LrDialogs'
local LrView = import 'LrView'
local LrColor = import 'LrColor'
local LrPathUtils = import 'LrPathUtils'
local LrFtp = import 'LrFtp'
local LrFileUtils = import 'LrFileUtils'
local LrErrors = import 'LrErrors'

return {
	--startDialog = function( propertyTable ) end,
	--endDialog = function( propertyTable, why )  end,
	-- Export fields to be remembered with default value
	showSections = {'exportLocation'},
	allowFileFormats = nil, -- nil equates to all available formats
	allowColorSpaces = nil, -- nil equates to all color spaces
	canExportToTemporaryLocation = true,
	--sectionsForBottomOfDialog = function( viewFactory, propertyTable ) end,
	processRenderedPhotos = function( functionContext, exportContext ) 
		local exportSession = exportContext.exportSession
		local nPhotos = exportSession:countRenditions()
		local progressScope = exportContext:configureProgress{
			title = nPhotos > 1
			and LOC("$$$/yalps/runme/export/dialogs/progress/several=Processing ^1 photos", nPhotos )
			or LOC"$$$/yalps/runme/export/dialogs/progress/one=Processing one photo",
		}
		for i, rendition in exportContext:renditions{ stopIfCanceled = true } do
			local photo = rendition.photo
			local success, pathOrMessage = rendition:waitForRender()
		
			if progressScope:isCanceled() then break end
			--Execute command here
			--if success then
			--	local filename = LrPathUtils.leafName( pathOrMessage )		
			--	LrDialogs.message(filename, pathOrMessage, "info" ) 
			--end
		end
	end,
}